package cn.zhage.aimin.canal.client.client;

import cn.zhage.aimin.canal.client.config.CanalProperties;
import cn.zhage.aimin.canal.client.handler.MessageHandler;
import com.alibaba.otter.canal.client.CanalConnector;
import com.alibaba.otter.canal.client.CanalConnectors;
import com.alibaba.otter.canal.protocol.Message;
import lombok.extern.slf4j.Slf4j;

import java.net.InetSocketAddress;
import java.util.List;

/*
 *
 * @author 渣哥
 */
@Slf4j
public class ClusterCanalClient extends AbstractCanalClient{

    public ClusterCanalClient(CanalProperties canalProperties, MessageHandler<Message> messageHandler) {
       super(canalProperties, messageHandler);
    }

    @Override
    public CanalConnector createConnector() {
        log.info("创建CanalConnector successfully!");
        List<InetSocketAddress> inetSocketAddresses = formatAddress();
        return CanalConnectors.newClusterConnector(inetSocketAddresses,
                canalProperties.getDestination(),
                canalProperties.getUsername(),
                canalProperties.getPassword());
    }


}
